<template>
	<view style="width: 700upx;padding: 25upx;overflow:hidden;">
		<view style="width: 700upx;font-size: 30upx;color: #333;line-height: 100upx;font-weight: bold;">{{title}}</view>
		<rich-text :nodes="agreement" style="word-break:break-all;white-space: pre-line;"></rich-text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nodes: [{
					name: 'div',
					attrs: {
						class: 'div-class',
						style: 'line-height: 60px; color: red; text-align:center;'
					},
					children: [{
						type: 'text',
						text: 'Hello&nbsp;uni-app!'
					}]
				}],
				agreement:'',
				news_id:'',
				title:'',
				addtime:''
			}
		},
		onLoad(num) {
			this.news_id = num.news_id
			this.news_detail_api()
		},
		methods: {
			news_detail_api() {
				var that = this
				that.$request(that.$Api.news_detail_api, {
					access_token: uni.getStorageSync('access_token'),
					news_id:that.news_id
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.title = res.data.data.list.title
						that.addtime = res.data.data.list.addtime
						var richtext=  res.data.data.list.content
						const regex = new RegExp('<img', 'gi');
						richtext= richtext.replace(regex, `<img style="max-width: 100%;"`);
						var fullContent = richtext.replace(/&nbsp;/g, '\xa0');
						this.agreement = fullContent
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
		}
	}
</script>

<style>
	page{
		/* padding-top: 30upx; */
	}
</style>
